home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
193_01
/
deff3.c
< prev
next >
Wrap
Text File
|
1985-11-13
|
18KB
|
504 lines
/*-----------------------------------------------------------------*/
/* LIBRARY FUNCTIONS ==> written by Phil Cogar */
/* For BDS C under CP/M 2.2 using the "BDOS" Function */
/* */
/* This file contains the following functions - */
/* */
/* CGET CPUT DIRECTC */
/* CLRSCREEN LISTC GET_IOBYTE */
/* SET_IOBYTE PRT_STR READ_STR */
/* CON_STAT GET_CPM RESET_DSK */
/* SELECT_DSK OPEN_FILE CLOSE_FILE */
/* SEARCH_FIRST SEARCH_NEXT CREATE_FILE */
/* ERASE_FILE READ_SEQ_SEC WRITE_SEQ_SEC */
/* GET_DEFAULT SET_DMA MAKE_RO */
/* SET_ATTRIBUTES USER_ID BITCOUNT */
/* BINARY SHELL_SORT REVERSE */
/* ITOA INDEX PRINT_DEC */
/* SWAP_POINTERS ISALNUM */
/* */
/* all of which are described in DEFF3.TXT and are */
/* contained in the linking file ==> DEFF3.CRL */
/* Copyright 1986 - Cogar Computer Services Pty. Ltd. */
/*-----------------------------------------------------------------*/
#include "pec.h" /* definitions required */
/*=================================================================*/
/* CGET */
/* Read Console Byte ==> CP/M Function No. 1 */
/* Note will read any BYTE value from the console */
cget()
{
bdos(READ,0);
}
/*-----------------------------------------------------------------*/
/* CPUT */
/* Write Console Byte ==> CP/M Function No. 2 */
/* Note will send any BYTE value to the console */
cput(c)
int c;
{
bdos(WRITE,c);
}
/*-----------------------------------------------------------------*/
/* CLRSCREEN */
/* Clear screen function for Hazeltine Esprit terminal */
clrscreen()
{
cput(126);
cput(28);
}
/*-----------------------------------------------------------------*/
/* LISTC */
/* List byte to line printer */
listc(c)
int c;
{
bdos(LIST, c);
}
/*-----------------------------------------------------------------*/
/* DIRECTC */
/* Use direct console IN/OUT ==> CP/M function No. 6 */
/* Note: DUTY = IN = 0FFH */
/* = OUT = character to be printed to screen */
/* Returns either the input character or Reg. A = 0 */
/*-----------------------------------------------------------------*/
#define IN 255 /* Character in function */
directc(DUTY)
int DUTY;
{
bdos(DCIO,DUTY);
}
/*-----------------------------------------------------------------*/
/* GET_IOBYTE */
/* Get IOBYTE setting */
/* Returns the current IOBYTE setting */
/*-----------------------------------------------------------------*/
get_iobyte()
{
bdos(IOBYTE,0);
}
/*-----------------------------------------------------------------*/
/* SET_IOBYTE */
/* Sets the IOBYTE */
/* Doesn't return anything */
/*-----------------------------------------------------------------*/
set_iobyte(IOB)
short IOB; /* new IOBYTE setting */
{
bdos(SET_IOBYTE,IOB);
}
/*-----------------------------------------------------------------*/
/* PRT_STR */
/* Print a "$" terminated string to the console */
/* Doesn't return anything */
/*-----------------------------------------------------------------*/
prt_str(BUFF)
char *BUFF; /* pointer to string buffer */
{
bdos(PRT_STRING,BUFF);
}
/*-----------------------------------------------------------------*/
/* READ_STR */
/* Read a "RETURN" terminated string from the console */
/* Note: The CR doesn't form part of the string. As written */
/* ---- this function terminates the string with a null. */
/*-----------------------------------------------------------------*/
#define BUFF_LEN 134 /* maximum number of characters */
read_str(BUFF)
short *BUFF;
{
short n;
for(n = 0; n <= BUFF_LEN; n++)
{
BUFF[n] = '\0'; /* Initialise string with NULL's */
}
BUFF[0] = BUFF_LEN; /* must tell CP/M buffer size */
bdos(READ_STRING,BUFF);
}
/*-----------------------------------------------------------------*/
/* CON_STAT */
/* Read the console status ==> CP/M Function No. 11 */
/* Returns NULL if no character waiting, else returns 0FFH */
/*-----------------------------------------------------------------*/
con_stat()
{
bdos(CON_STATUS,0);
}
/*-----------------------------------------------------------------*/
/* GET_CPM */
/* Get CP/M Version Number */
/* Number is returned in HL with the details - */
/* */
/* H = 00H for CP/M or H = 01H for MP/M */
/* L = 00H for all releases prior to 2.0 */
/* L = 20H for release 2.0, 21H for release 2.1, 22H for */
/* release 2.2, and so on. */
/*-----------------------------------------------------------------*/
get_cpm()
{
bdos(CPM_NUM,0);
}
/*-----------------------------------------------------------------*/
/* RESET_DSK */
/* Reset the disk system */
/* Typically used after a disk is changed */
/* Does not return anything */
/*-----------------------------------------------------------------*/
reset_dsk()
{
bdos(RESET,0);
}
/*-----------------------------------------------------------------*/
/* SELECT_DSK */
/* Select logical disk ==> CP/M Function No. 14 */
/* This makes the nominated disk the default disk */
/* Note: Drive A = 00H */
/* ---- Drive B = 01H, and so on */
/*-----------------------------------------------------------------*/
select_dsk(DISK)
short DISK;
{
toupper(DISK); /* make this upper case */
DISK = DISK - 66; /* convert to A = 0, B = 1, etc */
bdos(LOGICAL,DISK);
}
/*-----------------------------------------------------------------*/
/* OPEN_FILE */
/* Open a file ==> CP/M Function No. 15 */
/* To use this you must have previously formulated a File */
/* Control Block (FCB) using setfcb(fcbaddr, filename) */
/* Returns the Directory code in Register A, or 0FFH if it failed */
/* Note particularly the nominated FCB must be